<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="admin/common/common_css :: commonHeader('编辑用户密码')">
</head>
<body>
<article class="page-container">
    <form class="form form-horizontal" id="form-user-pswd-edit">
        <input type="hidden" name="userId" value="${editUser.userId }" />
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-4" style="text-align: right;"><span class="c-red">*</span>登录密码：</label>
            <div class="formControls col-xs-8 col-sm-9" style="width:58%;">
                <input type="password" class="input-text" placeholder="登录密码（必填，登录系统使用）" id="password" name="password" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-4 col-sm-4" style="text-align: right;"><span class="c-red">*</span>确认密码：</label>
            <div class="formControls col-xs-8 col-sm-9" style="width:58%;">
                <input type="password" class="input-text" placeholder="确认密码（必填，确保您密码输入正确）" id="rpassword" name="rpassword" maxlength="50" />
            </div>
        </div>
        <div class="row cl">
            <div style="text-align: center;">
                <button class="btn btn-primary radius" type="submit">
                    <i class="Hui-iconfont">&#xe632;</i> 保存
                </button>
                &nbsp;&nbsp;
                <button onClick="layer_close();" class="btn btn-default radius" type="button">
                    &nbsp;&nbsp;取消&nbsp;&nbsp;
                </button>
            </div>
        </div>
    </form>
</article>
<div th:include="admin/common/common_js :: onLoadJS"></div>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/jquery.validate.js}"></script>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/validate-methods.js}"></script>
<script type="text/javascript" th:src="@{/js/admin.ui/lib/jquery.validation/1.14.0/messages_zh.js"}></script>
<script type="text/javascript">
    $(function(){
        $("#form-user-pswd-edit").validate({
            rules:{
                password:{required:true, minlength:4, maxlength: 50},
                rpassword:{required:true, minlength:4, maxlength: 50, equalTo: "#password"}
            },
            onkeyup:false,
            focusCleanup:true,
            success:"valid",
            submitHandler:function(form){
                shiro.ajax({
                    url: '/sys/user/editPswd.action',
                    data:$('#form-user-pswd-edit').serialize(),
                    success: function(data) {
                        if(data.result == 0) {
                            layer.msg(data.message, {icon: 1,time: 1500}, function() {
                                window.parent.location.href = shiro.baseUrl + "/sys/user/list.action";
                            });
                        } else {
                            layer.msg(data.message, {icon: 5,time: 1500});
                            $('#password').focus();
                        }
                    }
                });
            }
        });
    });
</script>
</body>
</html>